#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
const int M = 1000;
const int N = 1000;
int image[M][N];
string image_r[M][N];

string i2s(int a){
    string b;
    while(a >= 0 && floor(a/10) >= 0 ){
        if(floor(a/10) == 0){
            b += a + '0';
            break;
        }else{
            b += a%10 +'0';
            a = floor(a/10);
        }
    }
    reverse(b.begin(), b.end());
    return b;
}

int main(){
    int m, n, a, b, t;
    cin >> m >> n >> a >> b >> t;
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < n; ++j){
            cin >> image[i][j];
            if(image[i][j] >= a && image[i][j] <= b){
                image[i][j] = t;
            }
            image_r[i][j] = i2s(image[i][j]);
            if(image[i][j] < 10) image_r[i][j] = "00" + image_r[i][j];
            else if(image[i][j] < 100) image_r[i][j] = '0' + image_r[i][j];
        }
    }

    // 格式化输出
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < n; ++j){
            cout << image_r[i][j];
            if(j < n - 1){
                cout << " ";
            }
        }
        if(i < m - 1){
            cout << endl;
        }
        
    }
    return 0;
}